﻿<?php include('app/admin/welcome/html/meta.html');?>
<?php include('app/admin/welcome/html/header.html');?>
<?php include('app/admin/welcome/html/menu.html');?>

<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> <a href="index.php?a=admin&b=welcome&c=index">首页</a>
		<span class="c-gray en">&gt;</span>
		管理员管理
		<span class="c-gray en">&gt;</span>
		管理员列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
				<a class="btn btn-primary radius" data-title="添加管理员" href="index.php?a=admin&b=maneger&c=add" ><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
				</span>
			</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="" value=""></th>
							<th width="80">Id</th>
							<th width="80">权限</th>
							<th width="80">账号</th>
							<th width="80">性别</th>
							<th width="80">昵称</th>
							<th width="120">注册时间</th>
							<th width="120">操作</th>
						</tr>
					</thead>
					<tbody id="tbody">
						<?php foreach($maneger as $k=>$v){?>
						<tr class="text-c">
							<td><input type="checkbox" value="" name=""></td>
							<td><?php echo $v['Id']?></td>
							<td><?php foreach($permission as $key=>$val){if($v['role_id']==$val['Id']){echo $val['name'];}}?></td>
							<td><?php echo $v['username'];?></td>
							<td><?php echo $v['sex'];?></td>
							<td><?php echo $v['nickname'];?></td>
							<td><?php echo date('Y-m-d h:i',$v['date']);?></td>
							<td class="f-14 td-manage">
								<?php if($v['freeze']==0){?>
										<a style="text-decoration:none" onClick="admin_start(this,'10001')" href="javascript:;" title="<?php echo '启动'?>" class="freeze" freeze="<?php echo '1'?>" freid="<?php echo $v['Id']?>"><i class="Hui-iconfont"><?php echo '&#xe615;'?></i></a>
										<?php }else if($v['freeze']==1){?>
										<a style="text-decoration:none" onClick="admin_start(this,'10001')" href="javascript:;" title="<?php echo '禁用'?>" class="freeze" freeze="<?php echo '0'?>" freid="<?php echo $v['Id']?>"><i class="Hui-iconfont"><?php echo '&#xe631;'?></i></a>	
								<?php }?>	
								<a style="text-decoration:none" class="ml-5" href="index.php?a=admin&b=maneger&c=update&id=<?php echo $v['Id']?>" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
								<a style="text-decoration:none" class="ml-5" href="index.php?a=admin&b=maneger&c=delete&id=<?php echo $v['Id'];?>" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
						</tr>
						<?php }?>
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>


<?php include('app/admin/welcome/html/footer.html');?>

<!--请在下方写此页面业务相关的脚本-->
<script>


/*管理员-启用*/
function admin_start(obj,id){
	var freezes = $(obj).attr('freeze');
	var ids = $(obj).attr('freid');
	layer.confirm('确认要启用吗？',function(index){
		$.ajax
		({
			url:'index.php?a=admin&b=maneger&c=freeze',
			type:'post',
			async:false,
			//contentType:false,
			//processData:false,
			data:{
				freeze:freezes,
				Id:ids
			},
			success:function(date)
			{
//				alert(date);
				//return false;
				if(date=='修改成功')
				{
//					alert('账号启动成功');
					return false;
				}else(date=='修改失败')
				{
//					alert('账号启用失败');
					return false;
				}
			}
		})
		//此处请求后台程序，下方是成功后的前台处理……

		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,id)" href="javascript:;" title="停用" style="text-decoration:none" class="freeze" freeze="0" freid="'+ids+'"><i class="Hui-iconfont">&#xe631;</i></a>');

		$(obj).remove();
		layer.msg('已启用!', {icon: 6,time:1000});
	});
}

/*管理员-停用*/
function admin_stop(obj,id){
	var freezes = $(obj).attr('freeze');
	var ids = $(obj).attr('freid');
	layer.confirm('确认要停用吗？',function(index){
		$.ajax
		({
			url:'index.php?a=admin&b=maneger&c=freeze',
			type:'post',
			async:false,
			//contentType:false,
			//processData:false,
			data:{
				freeze:freezes,
				Id:ids
			},
			success:function(date)
			{
				if(date=='修改成功')
				{
//					alert('账号冻结成功');
					return false;
				}else(date=='修改失败')
				{
//					alert('账号冻结失败');
					return false;
				}
			}
		})
		//此处请求后台程序，下方是成功后的前台处理……
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none" class="freeze" freeze="0" freid="'+ids+'"><i class="Hui-iconfont">&#xe615;</i></a>');

		$(obj).remove();
		layer.msg('已停用!',{icon: 5,time:1000});
	});
}
	
</script>
<!--/请在上方写此页面业务相关的脚本-->

</body>
</html>